﻿using System;
using System.Collections.Generic;
using Crocodile.CsharpLanguage.Tree;
using JetBrains.Annotations;



namespace Crocodile.CsharpLanguage.Coding
{
    public static class SharpenExt
    {

        public static string ToCode(this CsVisibility visibility)
        {
            switch (visibility)
            {
                case CsVisibility.Private:   return "private";
                case CsVisibility.Internal:  return "internal";
                case CsVisibility.Protected: return "protected";
                case CsVisibility.Public:    return "public";
                default: throw new InvalidOperationException();
            }
        }


        public static void Add([NotNull] this IList<CsStatement> content, 
                               [CanBeNull] string text)
        {
            if (text == null)
                return;

            var stmt = new CsRandomStatement();
            stmt.AddText(text);
            content.Add(stmt);
        }


        [StringFormatMethod("template")]
        public static void Add([NotNull] this IList<CsStatement> content,
                               [NotNull] string template,
                               params object[] args)
        {
            var stmt = new CsRandomStatement();
            stmt.AddText(template, args);
            content.Add(stmt);
        }

    }
}
